package com.liuyk.commonlib.network;

import com.liuyk.commonlib.network.request.BaseFileRequest;
import com.liuyk.commonlib.network.request.BaseRequest;

/**
 * 网络请求的入口
 * <p>
 * Created by liuyakui on 2020/1/18.
 */
public final class HttpUtils {

    private HttpUtils() {
    }

    public static <T> void delete(BaseRequest request, NetworkCallBack<T> callBack) {
        RealCall.getInstance().delete(request, callBack);
    }

    public static <T> void put(BaseRequest request, NetworkCallBack<T> callBack) {
        RealCall.getInstance().put(request, callBack);
    }

    //上传文件
    public static <T> void postFile(BaseFileRequest request, NetworkCallBack<T> callBack) {
        RealCall.getInstance().postFile(request, callBack);
    }

    public static <T> void post(BaseRequest request, NetworkCallBack<T> callBack) {
        RealCall.getInstance().post(request, callBack);
    }

    public static <T> void get(BaseRequest request, NetworkCallBack<T> callBack) {
        RealCall.getInstance().get(request, callBack);
    }

    public static void cancel(String url) {
        RealCall.getInstance().cancel(url);
    }

//    public static class Builder {
//        private Map<String, String> mParams;
//        private String url;
//
//        Builder(String url) {
//            this.url = url;
//            mParams = new HashMap<>();
//        }
//
//        public Builder params(String key, String value) {
//            mParams.put(key, value);
//            return this;
//        }
//
//        public Builder maps(Map<String, String> params) {
//            if (params != null) {
//                mParams = params;
//            }
//            return this;
//        }
//
//        public HttpUtils builder() {
//            return new HttpUtils(url, mParams);
//        }
//    }

//    public static Builder loadData(String url) {
//        return new Builder(url);
//    }
}
